import java.io.IOException;
import java.util.ArrayList;
import java.util.List;

import com.gargoylesoftware.htmlunit.BrowserVersion;
import com.gargoylesoftware.htmlunit.DefaultCredentialsProvider;
import com.gargoylesoftware.htmlunit.HttpMethod;
import com.gargoylesoftware.htmlunit.Page;
import com.gargoylesoftware.htmlunit.WebClient;
import com.gargoylesoftware.htmlunit.WebRequest;
import com.gargoylesoftware.htmlunit.util.NameValuePair;
import com.gargoylesoftware.htmlunit.util.UrlUtils;
import com.qq.spirit.GameConstants;
import com.qq.spirit.HttpUtil;

public class GameTest
{
	// static final WebClient webClient = new
	// WebClient(BrowserVersion.INTERNET_EXPLORER_8,"proxy.tencent.com",8080);
	static final WebClient webClient = new WebClient(BrowserVersion.INTERNET_EXPLORER_8);
	static
	{
		// final DefaultCredentialsProvider credentialsProvider =
		// (DefaultCredentialsProvider) webClient.getCredentialsProvider();
		// credentialsProvider.addCredentials("beedoorwei", "959624Xl");
		webClient.setJavaScriptEnabled(false);
		webClient.setCssEnabled(false);
	}

	public static void main(String args[])
	{
		try
		{
			webClient.addRequestHeader("Cookie", "JSESSIONID=1B03559C2141E7CE7B075C04ED4CBB92");
			WebRequest wr = new WebRequest(UrlUtils.toUrlSafe(GameConstants.CARAVAN_QUERY_URL));
			List<NameValuePair> nvpList = new ArrayList<NameValuePair>();
			nvpList.add(new NameValuePair("campaignId", "18"));
			nvpList.add(new NameValuePair("init", "1"));
			wr.setRequestParameters(nvpList);
			wr.setHttpMethod(HttpMethod.GET);
			Page p = webClient.getPage(wr);
			System.out.println(HttpUtil.decodeResponse(p));
		} catch (Exception e)
		{
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
	}
}
